<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //---------set集合
        // const a = "a";
        // const b = "b";
        // const c = "c";

        // const letters = new Set();

        // letters.add(a);
        // letters.add(b);
        // letters.add(c);
        // console.log(letters)//{'a','b','c'}

        //对象
        // const letters = new Set();
        // letters.add("a");
        // letters.add("b");
        // letters.add("c");
        // console.log(letters)//{'a','b','c'}
        // console.log(typeof letters) //object
        // console.log(letters instanceof Set) //true

        //数组
        // const letters = new Set([{a:1}]);
        // letters.add({b:"2"});
        // letters.add(3);
        // letters.add("c");
        // console.log(letters)//[{a:1},{b:"2"},3,"c"]


        //---------map集合
        //示例1
        // const apples = {name: 'Apples'};
        // const bananas = {name: 'Bananas'};
        // const oranges = {name: 'Oranges'};

        // const fruits = new Map();

        // fruits.set(apples, 500);
        // fruits.set(bananas, 300);
        // fruits.set(oranges, 200);
        // console.log(fruits)//[{{name: 'Apples'}:500},{{name: 'Bananas'}:300},{{name: 'Oranges'}:200}]

        //示例2
        const apples = {name: 'Apples'};
        const bananas = {name: 'Bananas'};
        const oranges = {name: 'Oranges'};

        // 创建新的 Map
        const fruits = new Map([
        [apples, 500],
        [bananas, 300],
        [oranges, 200]
        ]);
        console.log(fruits)
        console.log(fruits.get(apples))//500   获取map中键的值
        console.log(fruits.keys())
        console.log(fruits.values())


    </script>
</head>
<body>
    
</body>
</html>
